@using EventHub.Options
@using EventHub.Web
@using EventHub.Web.Pages.Events
@using Microsoft.Extensions.Options
@model List<EventHub.Events.EventInListDto>
@inject IOptions<EventHubUrlOptions> UrlOptions

@foreach (var eventDto in Model)
{
    <div class="col-lg-4 col-md-6 event">
        <div class="card">
            <div class="event-thumbnail" style="background-image: url(@(UrlOptions.Value.Api.EnsureEndsWith('/') + $"api/eventhub/event/cover-image/{eventDto.Id}")" alt="@eventDto.Title">
            </div>
            <div class="card-body">
                <div class="event-container">
                    <div class="row">
                        <div class="col-3">
                            <div class="event-date text-center">
                                <small>@eventDto.StartTime.ToString("MMM")</small>
                                <span>@eventDto.StartTime.Day</span>
                            </div>
                        </div>
                        <div class="col-9">
                            <div class="event-info">
                                <h5>@eventDto.Title</h5>
                                <small>@EventDateHelper.GetTimeRangeText(TimeOnly.FromDateTime(eventDto.StartTime), TimeOnly.FromDateTime(eventDto.EndTime)) | @EventDateHelper.GetLocationInfo(eventDto)</small>
                                <p>@eventDto.Description</p>
                            </div>
                            <a href="@Url.Page("/Events/Detail", new { url = eventDto.Url })" class="btn btn-link p-0">Learn More <img src="/assets/more-btn.svg"></a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
}
